Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Load cuSparse and cuSolver library for preparing sparse matrix on GPU #4904

Closed
wants to merge 9 commits into from

Conversation

Hanke98
Copy link
Contributor

@Hanke98 Hanke98 commented May 4, 2022

Related issue = #2906

Start to support sparse matrix on CUDA backend from this pr.

We first load the cuSparse and cuSolver libs via the DynamicLoader class in this pr.

A new class, CUDADriverBase is introduced as the base class for the driver classes of these libs, which might also be helpful for the potential libs that we can use in the future.

@netlify
Copy link

netlify bot commented May 4, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 222abef
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/628347603520e90008465bdb
😎 Deploy Preview https://deploy-preview-4904--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Hanke98
Copy link
Contributor Author

Hanke98 commented May 17, 2022

Sorry for the delayed update. Now, the cuSolver and cuSpasrse libraries can be opened via CUSOLVERDriver and CUSPARSEDriver. And the concrete APIs for accessing those libraries will be updated in the following pr.

BTW, should we add flags to indicate whether we should load those libraries, like TI_ENABLE_CUSPARSE?
@FantasyVR could you please have a look? Thanks!

@FantasyVR
Copy link
Collaborator

Hi @Hanke98, thanks very much.

BTW, should we add flags to indicate whether we should load those libraries, like TI_ENABLE_CUSPARSE?

Maybe we could use another approach. When using the sparse matrix with arch=ti.gpu, we could detect if cuSolver and cuSpasrse libraries are installed. If the libraries are not installed we could generate error messages instead.

How do you guys think @k-ye, @strongoier ?

}
}

CUSPARSEDriver::CUSPARSEDriver() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd suggest not to do this in the constructor, becuase if the lib fails to load, we get a broken/zombie object. A safer approach could be to load DLL in a function. If that fails, returns the exception/error to Python. Otherwise move that loaded lib into CuSolverDriver.

Also, we need to make sure not accidentally invoke CUSPARSEDRiver::get_instance() when we don't need the sparse matrix, otherwise Taichi could be broken if cuSparse is not installed.

I know this is not a newly introduced problem, so this is just something to think about :-)

@k-ye
Copy link
Member

k-ye commented May 17, 2022

If the libraries are not installed we could generate error messages instead.

SG! TBH I was initially thinking something like torch's tags, e.g. pip install torch==1.7.1+cu110. But I think that would require us to maintain more PyPI pkgs, so probably not worth it at this point..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants